home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / tde40.zip / cfgmacro.c < prev    next >
C/C++ Source or Header  |  1994-06-05  |  2KB  |  77 lines

  1. /*
  2.  * This module contains all the routines needed to save an existing macro
  3.  * definition file in tde.exe
  4.  *
  5.  * Program Name:  tdecfg
  6.  * Author:        Frank Davis
  7.  * Date:          October 5, 1991
  8.  */
  9.  
  10. #include <io.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14.  
  15. #include "tdecfg.h"
  16. #include "cfgmacro.h"
  17.  
  18. extern struct vcfg cfg;
  19. extern FILE *tde_exe;                  /* FILE pointer to tde.exe */
  20. extern long macro_offset;
  21.  
  22. static WINDOW *w_ptr;
  23.  
  24. MACRO macros;
  25.  
  26.  
  27. /*
  28.  * Name:    tdehelp
  29.  * Date:    October 1, 1991
  30.  * Notes:   Set up most of the window global variables.
  31.  */
  32. void tdemacro( void )
  33. {
  34. int c;
  35. char fname[82];
  36. FILE *macro_file;                  /* FILE pointer to macro */
  37.  
  38.  
  39.    cls( );
  40.    show_box( 0, 0, macro_screen, NORMAL );
  41.    xygoto( 42, 14 );
  42.    c = getkey( );
  43.    while (c != '1' && c != '2')
  44.       c = getkey( );
  45.    if (c == '1') {
  46.       puts( "" );
  47.       puts( "" );
  48.       puts( "" );
  49.       puts( "Enter file name that contains the macro definitions :" );
  50.       gets( fname );
  51.       if ((c = access( fname, EXIST )) != 0) {
  52.          puts( "\nFile not found.  Press any key to continue." );
  53.          c = getkey( );
  54.          cls( );
  55.          return;
  56.       } else if ((macro_file = fopen( fname, "rb" )) == NULL ) {
  57.          puts( "\nCannot open macro file.  Press any key to contine." );
  58.          c = getkey( );
  59.          cls( );
  60.          return;
  61.       }
  62.  
  63.       fread( (void *)¯os.first_stroke[0], sizeof(int), MAX_KEYS, macro_file );
  64.       fread( (void *)¯os.strokes[0], sizeof(STROKES), STROKE_LIMIT, macro_file );
  65.       fseek( tde_exe, macro_offset + 8, SEEK_SET );
  66.       fwrite( (void *)¯os.first_stroke[0], sizeof(int), MAX_KEYS, tde_exe );
  67.       fwrite( (void *)¯os.strokes[0], sizeof(STROKES), STROKE_LIMIT, tde_exe );
  68.       fclose( macro_file );
  69.       puts( "" );
  70.       puts( "" );
  71.       puts( "" );
  72.       puts( "New macros successfully installed.  Press any key to continue." );
  73.       c = getkey( );
  74.    }
  75.    cls( );
  76. }
  77.